package cn.holy.app.xcddt.net


import cn.holy.app.xcddt.domain.RecordBean
import cn.holy.app.xcddt.domain.RecordCheckBean
import cn.holy.app.xcddt.domain.RecordGroup
import cn.holy.app.xcddt.domain.UserBean
import cn.holy.app.xcddt.domain.net.ApiResponse
import okhttp3.RequestBody
import retrofit2.Call
import retrofit2.http.*
import rx.Observable
import java.util.*

/**
 * Created by xionghao on 2018/2/23.
 */

interface Webservice {
    /**
     * 登录接口
     *
     * @param username 账号
     * @param password 密码
     * @return 登录成功后返回用户数据
     */
    @FormUrlEncoded
    @POST("/api/auth/login")
    fun login(@Field("username") username: String, @Field("password") password: String): Observable<ApiResponse<UserBean>>


    @POST("/api/archive/upload")
    fun upload(@Body body: RequestBody): Observable<ApiResponse<String>>

    @POST("/api/archive/check")
    fun uploadCheck(@Body body: RequestBody): Observable<ApiResponse<RecordCheckBean>>

    @GET("/api/archive")
    fun archives(@Query("page") page: Int, @Query("status") status: Int): Observable<ApiResponse<ArrayList<RecordBean>>>

    @GET("/api/archive/group")
    fun archivesByGroup(@Query("page") page: Int): Observable<ApiResponse<ArrayList<RecordGroup>>>

    @GET("/api/archive/record_num")
    fun recordNum(): Observable<ApiResponse<Int>>

    @GET("/api/archive/record_count")
    fun recordCount(@Query("record_num") number: Int): Observable<ApiResponse<Int>>

    @FormUrlEncoded
    @POST("/api/bind")
    fun savePhone(@Field("phone") phone: String): Observable<ApiResponse<UserBean>>

    @GET("/api/refresh")
    fun refreshToken():Call<String>



}
